package com.multithreading.ThreadPool_001;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zx
 * @version 1.0
 * @package_name: com.multithreading.ThreadPool_001
 * @date 2024/5/20 9:41
 */
public class MyThreadPoolDemo {
    public static void main(String[] args) {
        // 创建线程池
        ExecutorService pool1 = Executors.newCachedThreadPool();
        //ExecutorService pool1 = Executors.newCachedThreadPool(3);

        //提交任务
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());


        //关闭线程池
        pool1.shutdown();
    }
}
